import java.util.LinkedList;
import java.util.Queue;

public class Main {
    public static void dfs(Node root){
        if(root == null){
            return;
        }
        Queue<Node> queue = new LinkedList<>();
        queue.offer(root);
        while(!queue.isEmpty()){
            int N = queue.size();
            for(int i = 0; i<N; i++){
                Node p = queue.poll();
                if(p == null){
                    System.out.print("null"+"\t");
                }else{
                    System.out.print(p.val);
                    System.out.print("\t");
                    queue.offer(p.left);
                    queue.offer(p.right);
                }
            }
            System.out.println();
        }
    }






    public static void main(String[] args) {

        RBT rbt = new RBT();
        Node root = rbt.insert(null,1);
        Node root1 = rbt.insert(root,2);
        for(int i = 3; i<11; i++){
            Node roo = rbt.insert(root1,i);
            root1 = roo;
        }
        dfs(root1);




















    }
}
